package com.link2room.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.integration.redis.util.RedisLockRegistry;

@Configuration
public class RedisLockConfig {

    @Bean(name = "membercardPrepayIdLock")
    public RedisLockRegistry getMembercardPrepayIdLock(RedisTemplate redisTemplate) {
        return new RedisLockRegistry(redisTemplate.getConnectionFactory(), "MembercardPrepayLock");
    }

    @Bean(name = "membercardPayLock")
    public RedisLockRegistry getMembercardPayLock(RedisTemplate redisTemplate) {
        return new RedisLockRegistry(redisTemplate.getConnectionFactory(), "MembercardPayLock");
    }

    @Bean(name = "inmailIdGenerateLock")
    public RedisLockRegistry getMasterIdGenerateLock(RedisTemplate redisTemplate){
        return  new RedisLockRegistry(redisTemplate.getConnectionFactory(),"InmailIdGenerateLock");
    }

    @Bean(name = "inmailReadStaCountLock")
    public RedisLockRegistry getInmailStaLock(RedisTemplate redisTemplate){
        return  new RedisLockRegistry(redisTemplate.getConnectionFactory(),"InmailReadStaCountLock");
    }

    @Bean(name = "inmailDoneStaCountLock")
    public RedisLockRegistry getInmailDoneStaCountLock(RedisTemplate redisTemplate){
        return  new RedisLockRegistry(redisTemplate.getConnectionFactory(),"InmailDoneStaCountLock");
    }

    @Bean(name = "mnsLogLock")
    public RedisLockRegistry getLockRegistry(RedisTemplate redisTemplate){
        return  new RedisLockRegistry(redisTemplate.getConnectionFactory(),"MNSLogLock");
    }

    /**
     * 抽奖锁-activityCode 活动码
     * @param redisTemplate
     * @return
     */
    @Bean(name = "doDrawLock")
    public RedisLockRegistry getdoDrawLockRegistry(RedisTemplate redisTemplate){
        return  new RedisLockRegistry(redisTemplate.getConnectionFactory(),"doDrawLock");
    }

    /**
     * 电子券-流水号锁
     * @param redisTemplate
     * @return
     */
    @Bean(name = "couponNoLock")
    public RedisLockRegistry newCouponLockRegistry(RedisTemplate redisTemplate){
        return  new RedisLockRegistry(redisTemplate.getConnectionFactory(),"couponNoLock");
    }
    /**
     * 抽奖-流水号锁
     * @param redisTemplate
     * @return
     */
    @Bean(name = "drawNoLock")
    public RedisLockRegistry newDrawNoLockRegistry(RedisTemplate redisTemplate){
        return  new RedisLockRegistry(redisTemplate.getConnectionFactory(),"drawNoLock");
    }

    /**
     * 快递流水号生产
     * @param redisTemplate
     * @return
     */
    @Bean(name = "expressLock")
    public RedisLockRegistry expressLockRegistry(RedisTemplate redisTemplate){
        return  new RedisLockRegistry(redisTemplate.getConnectionFactory(),"expressLock");
    }

    /**
     * 同步分销员奖励-lhotelGroupCode + lhotelCode + memberWxOpenid + notimeArr
     * @param redisTemplate
     * @return
     */
    @Bean(name = "syncSalesmanIncomingDetailLock")
    public RedisLockRegistry syncSalesmanIncomingDetailLock(RedisTemplate redisTemplate){
        return  new RedisLockRegistry(redisTemplate.getConnectionFactory(),"syncSalesmanIncomingDetailLock");
    }

    /**
     * 分销员奖励 Payment-单号生成
     * @param redisTemplate
     * @return
     */
    @Bean(name = "salesmanPaymentNoLock")
    public RedisLockRegistry salesmanPaymentNoLock(RedisTemplate redisTemplate){
        return  new RedisLockRegistry(redisTemplate.getConnectionFactory(),"salesmanPaymentNoLock");
    }

    /**
     * 团购开团流水号
     * @param redisTemplate
     * @return
     */
    @Bean(name = "createGroupBuyingTeamNoLock")
    public RedisLockRegistry createGroupBuyingTeamNoLock(RedisTemplate redisTemplate){
        return  new RedisLockRegistry(redisTemplate.getConnectionFactory(),"createGroupBuyingTeamNoLock");
    }

    /**
     * 商城订单流水号
     * @param redisTemplate
     * @return
     */
    @Bean(name = "mallOrderNoLock")
    public RedisLockRegistry mallOrderNoLock(RedisTemplate redisTemplate){
        return  new RedisLockRegistry(redisTemplate.getConnectionFactory(),"mallOrderNoLock");
    }

    /**
     * 团购团队锁
     * @param redisTemplate
     * @return
     */
    @Bean(name = "groupbuyingTeamCodeLock")
    public RedisLockRegistry groupbuyingTeamCodeLock(RedisTemplate redisTemplate){
        return  new RedisLockRegistry(redisTemplate.getConnectionFactory(),"groupbuyingTeamCodeLock");
    }

    /**
     * 签到分发
     * @param redisTemplate
     * @return
     */
    @Bean(name = "distributeAwardLock")
    public RedisLockRegistry distributeAwardLock(RedisTemplate redisTemplate){
        return  new RedisLockRegistry(redisTemplate.getConnectionFactory(),"distributeAwardLock");
    }

    /**
     * 签到助力计算次数锁
     * @param redisTemplate
     * @return
     */
    @Bean(name = "signReissueLcok")
    public RedisLockRegistry signReissueShareLcok(RedisTemplate redisTemplate){
        return  new RedisLockRegistry(redisTemplate.getConnectionFactory(),"signReissueLcok");
    }

    @Bean(name = "signInCodeLock")
    public RedisLockRegistry signInCodeLock(RedisTemplate redisTemplate){
        return  new RedisLockRegistry(redisTemplate.getConnectionFactory(),"signInCodeLock");
    }
}